package com.china08.yxyapi.api.manage.tec.teaching.zujuan.manualpaper;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.service.manage.tec.teaching.zujuan.ZujuanQuestionService;

import io.swagger.annotations.ApiOperation;

/***
 * 
 * 手动组卷--计算做题时间
 */
@RestController
@CrossOrigin
public class ZujuanQuesQuestionTimeController extends YxyApiBaseController {

    @Autowired
    private ZujuanQuestionService zujuanQuestionService;

    @ApiOperation(value = "计算试题时间")
    @RequestMapping(value = "/api_yw/manage/tec/teaching/zujuan/ques/questiontime", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel) {
        List<String> quesIds = reqModel.quesIds;
        double dateTime = 0.0;
        for (String quesId : quesIds) {
            dateTime = dateTime + zujuanQuestionService.questionDateTime(quesId);
        }
        RespModel model = new RespModel();
        model.date = dateTime;
        return model;
    }

    protected static class ReqModel {
        public List<String> quesIds;
    }

    protected static class RespModel {
        public double date;
    }

}
